<?php

namespace app\model;

use app\BaseModel;
use app\model\not_del\UserModel as NotDelUserModel;
use think\model\relation\BelongsTo;

/**
 * 咨询-心理评估
 */
class ConsultEvaluateModel extends BaseModel
{
    protected $name = 'consult_evaluate';

    /**
     * 关联咨询用户
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class,  'uid')->bind([
            'user_name' => 'name',
            'user_avatar' => 'avatar'
        ]);
    }

    /**
     * 关联咨询师
     * @return BelongsTo
     */
    public function consult(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class, 'consult_id')->bind([
            'consult_name' => 'name',
            'consult_avatar' => 'avatar',
            'consult_online_num',
            'consult_offline_num',
            'consult_evaluate_num',
            'consult_age' => 'age',
            'consult_sex' => 'sex',
        ]);
    }

    /**
     * 关联预约时间段
     * @return BelongsTo
     */
    public function consultTime(): BelongsTo
    {
        return $this->belongsTo('ConsultTimeModel', 'time_id')->bind([
            'reservation_start_time' => 'start_time',
            'reservation_end_time' => 'end_time'
        ]);
    }
}